#pragma once

#include <stdint.h>
#include <string>
#include <memory>

namespace db
{

class MySqlConf
{
public:
    using ptr = std::shared_ptr<MySqlConf>;

    MySqlConf()
    {

    }

    MySqlConf(const std::string& db
                , const std::string& user, const std::string& password
                , const std::string& ip = "127.0.0.1", uint16_t port = 3306)
        : m_strDB(db)
        , m_strIp(ip)
        , m_nPort(port)
        , m_strUser(user)
        , m_strPassword(password)
    {

    }

    void setDb(const std::string& strDb) { m_strDB = strDb; }
    void setUser(const std::string& strUser) {m_strUser = strUser; }
    void setPassword(const std::string& strPassword) { m_strPassword = strPassword; }
    void setIp(const std::string& strIp) { m_strIp = strIp; }
    void setPort(const uint16_t& nPort) { m_nPort = nPort; }

    std::string getDb() const { return m_strDB; }
    std::string getUser() const {return m_strUser; }
    std::string getPassword() const {return m_strPassword; }
    std::string getIp() const { return m_strIp; }
    uint16_t getPort() const {return m_nPort; }

    bool parseFromJson(const std::string& strJson);

private: 
    std::string m_strDB;
    std::string m_strUser;
    std::string m_strPassword;
    std::string m_strIp;
    uint16_t    m_nPort;
};

} // namespace db 
